﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
    Inherits="System.Web.Mvc.ViewPage<IOrder>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%: "Order Details".Localize()%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="title">
        <%:"Order #".Localize() %><%: this.Model.Id %>
        <a href="<%: this.ViewData["ReturnUrl"] %>">
            <%: "Back to list".Localize() %></a>
    </h3>
    <div class="order-form clearfix">
        <div class="common-form left">
            <fieldset>
                <legend>
                    <%:"Order info".Localize() %></legend>
                <table>
                    <tbody>
                        <tr>
                            <th>
                                <label>
                                    <%: "Order date".Localize()%></label>
                            </th>
                            <td>
                                <%: this.Model.OrderDate%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label for="status">
                                    <%: "Status".Localize()%></label>
                                <a class="tooltip-link" href="javascript://"></a>
                                <div class="hide">
                                    <p>
                                        <h6>
                                            <%:"PaymentPending:".Localize() %></h6>
                                        <%:"PaymentStatus_PaymentPending_Summary".Localize()%>
                                    </p>
                                    <p>
                                        <h6>
                                            <%:"InProgress:".Localize() %></h6>
                                        <%:"PaymentStatus_InProgress_Summary".Localize()%>
                                    </p>
                                    <p>
                                        <h6>
                                            <%:"DeliveryCompleted:".Localize() %></h6>
                                        <%:"PaymentStatus_DeliveryCompleted_Summary".Localize()%>
                                    </p>
                                    <p>
                                        <h6>
                                            <%:"DeliveryReturn:".Localize() %></h6>
                                        <%:"PaymentStatus_DeliveryReturn_Summary".Localize()%>
                                    </p>
                                    <p>
                                        <h6>
                                            <%:"Drawback:".Localize() %></h6>
                                        <%:"PaymentStatus_Drawback_Summary".Localize()%>
                                    </p>
                                    <p>
                                        <h6>
                                            <%:"Cancel:".Localize() %></h6>
                                        <%:"PaymentStatus_Cancel_Summary".Localize()%>
                                    </p>
                                    <p>
                                        <h6>
                                            <%:"Alert:".Localize() %></h6>
                                        <%:"PaymentStatus_Alert_Summary".Localize()%>
                                    </p>
                                </div>
                            </th>
                            <td>
                                <% using (Html.BeginForm("ChangeStatus", "Order", FormMethod.Post, new { id = "changestatusform" }))
                                   { %>
                                <%: Html.HiddenFor(i => i.Id)%>
                                <%: Html.DropDownList("status", ViewData["OrderStatus"] as IEnumerable<SelectListItem>, new { id = "status", disabled = "disabled" })%>
                                <a class="o-icon edit form-action status-edit-button" href="javascript:;" title="Edit">
                                    <%:"Edit".Localize() %></a> <a class="o-icon save form-action status-save-button hide" href="javascript:;"
                                        title="Save">
                                        <%:"Save".Localize() %></a> <a class="o-icon cancel form-action status-cancel-button hide"
                                            href="javascript:;" title="Cancel">
                                            <%:"Cancel".Localize() %></a>
                                <%} %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%: "Payment info".Localize()%></label>
                            </th>
                            <td>
                                <%: this.Model.PaymentName%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%: "Customer Name".Localize()%></label>
                            </th>
                            <td>
                                <a href='<%= ViewData["customer_view_action"] %>'>
                                    <%: this.Model.Customer.FullName() %>
                                </a>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%: "EMail".Localize()%></label>
                            </th>
                            <td>
                                <%: this.Model.Customer == null? "":this.Model.Customer.MailAddress%>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
        </div>
        <div class="common-form right">
            <fieldset>
                <legend>
                    <%: "Order totals".Localize()%></legend>
                <table>
                    <tbody>
                        <tr>
                            <th>
                                <%: "Subtotal".Localize()%>
                            </th>
                            <td>
                                <%: this.Model.SubTotal.ToString("c")%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <%: "Shipping & Handling".Localize()%>
                            </th>
                            <td>
                                <%: this.Model.ShippingCost.ToString("c")%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <%: "Payment Method".Localize()%>
                            </th>
                            <td>
                                <%:this.Model.PaymentMethodCost.ToString("c")%>
                            </td>
                        </tr>
                             <!--
                        <tr>
                            <th>
                                <%: "Grand Total".Localize()%>
                            </th>
                            <td>
                                <%: (this.Model.SubTotal + this.Model.ShippingCost + this.Model.PaymentMethodCost).ToString("c")%>
                            </td>
                        </tr>
                   
                        <tr>
                            <th>
                                <%: "Total Paid".Localize()%>
                            </th>
                            <td>
                                <%: (this.Model.SubTotal + this.Model.ShippingCost + this.Model.PaymentMethodCost).ToString("c")%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <%: "Total Refunded".Localize()%>
                            </th>
                            <td>
                                <%: this.Model.TotalDiscount.ToString("c")%>
                            </td>
                        </tr>
                        -->
                        <tr>
                            <th>
                                <%: "Total Tax".Localize() %>
                            </th>
                            <td>
                                <%: this.Model.TotalTaxCost.ToString("C") %>
                            </td>
                        </tr>
                        <tr>
                        <th>
                            <%: "Total Discount".Localize() %>
                        </th>
                        <td>
                            <%: this.Model.TotalDiscount.ToString("C") %>
                        </td>
                        </tr>
                        <tr>
                            <th>
                                <%: "Total due".Localize()%>
                            </th>
                            <td>
                                <%: (this.Model.Total + this.Model.ShippingCost + this.Model.PaymentMethodCost + this.Model.TotalTaxCost - this.Model.TotalDiscount).ToString("c")%>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
        </div>
    </div>
    <div class="table-container">
        <table>
            <thead>
                <tr>
                    <th>
                        <%: "Name".Localize() %>
                    </th>
                    <th>
                        <%: "Variation".Localize()%>
                    </th>
                    <th>
                        <%: "SKU".Localize() %>
                    </th>
                    <th class="numeral">
                        <%: "Quantity".Localize() %>
                    </th>
                    <th class="numeral">
                        <%: "Total".Localize() %>
                    </th>
                </tr>
            </thead>
            <tbody>
                <% 
                    var isEven = true;
                    foreach (var item in this.Model.OrderItems)
                    {
                        isEven = !isEven;
                %>
                <tr class="<%: isEven?"even":"" %>">
                    <td>
                        <a class="product-view-link" href="javascript:void(0);">
                            <%: item.ProductName%></a>
                        <div class="product-view hide">
                            <span></span>
                            <div class="common-form">
                                <fieldset>
                                    <table>
                                        <tbody>
                                            <% foreach (var i in item.OrderItemCustomFields)
                                               { %>
                                            <tr>
                                                <th>
                                                    <%= i.Name%>
                                                </th>
                                                <td>
                                                    <%= i.Value%>
                                                </td>
                                            </tr>
                                            <%}%>
                                        </tbody>
                                    </table>
                                </fieldset>
                            </div>
                        </div>
                    </td>
                    <td>
                        <a class="product-view-link" href="javascript:void(0);">
                            <%: string.Join("-", item.OrderItemVariations.Select(i => i.Value).ToArray())%></a>
                        <div class="product-view hide">
                            <span></span>
                            <div class="common-form">
                                <fieldset>
                                    <table>
                                        <tbody>
                                            <% foreach (var i in item.OrderItemVariations)
                                               { %>
                                            <tr>
                                                <th>
                                                    <%= i.Name%>
                                                </th>
                                                <td>
                                                    <%= i.Value%>
                                                </td>
                                            </tr>
                                            <%}%>
                                        </tbody>
                                    </table>
                                </fieldset>
                            </div>
                        </div>
                    </td>
                    <td>
                        <%: item.SKU %>
                    </td>
                    <td class="numeral">
                        <%: item.Quantity%>
                    </td>
                    <td class="numeral">
                        <%: item.SubTotal.ToString("c")%>
                    </td>
                </tr>
                <%}%>
            </tbody>
        </table>
    </div>
    <div class="order-form clearfix">
        <div class="common-form left">
            <fieldset>
                <legend>
                    <%:"Shipping address".Localize() %> </legend>
                <table>
                    <tbody>
                        <tr>
                            <th>
                                <label>
                                    <%:"First name".Localize() %></label>
                            </th>
                            <td>
                                <%:this.Model.FirstName%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Last name".Localize() %></label>
                            </th>
                            <td>
                                <%: this.Model.LastName%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Phone".Localize() %></label>
                            </th>
                            <td>
                                <%: this.Model.Phone%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Address".Localize() %></label>
                            </th>
                            <td>
                                <%: this.Model.Address1%>
                                <br />
                                <%: this.Model.Address2%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Country".Localize() %></label>
                            </th>
                            <td>
                                <%:this.Model.Country %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"State".Localize() %></label>
                            </th>
                            <td>
                                <%:this.Model.State %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"City".Localize() %></label>
                            </th>
                            <td>
                                <%:this.Model.City %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Postcode".Localize() %></label>
                            </th>
                            <td>
                                <%: this.Model.Postcode%>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
        </div>
        <div class="common-form right">
            <fieldset>
                <legend>
                    <%: "Billing address".Localize()%>
                </legend>
                <table>
                    <tbody>
                        <tr>
                            <th>
                                <label>
                                    <%: "First name".Localize()%></label>
                            </th>
                            <td>
                                <%: this.Model.InvoiceFirstName%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Last name".Localize() %></label>
                            </th>
                            <td>
                                <%: this.Model.InvoiceLastName %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Phone number".Localize()%></label>
                            </th>
                            <td>
                                <%: this.Model.InvoicePhone %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Address".Localize() %></label>
                            </th>
                            <td>
                                <%: this.Model.InvoiceAddress1 %>
                                <%: this.Model.InvoiceAddress2 %>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Country".Localize() %></label>
                            </th>
                            <td>
                                <%:this.Model.InvoiceCountry%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"State".Localize() %></label>
                            </th>
                            <td>
                                <%:this.Model.InvoiceState%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"City".Localize() %></label>
                            </th>
                            <td>
                                <%:this.Model.InvoiceCity%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Postcode".Localize() %></label>
                            </th>
                            <td>
                                <%: this.Model.InvoicePostcode %>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
        </div>
    </div>
    <div class="common-form order-form">
        <% using (Html.BeginForm("UpdateRemark", "Order", FormMethod.Post, new { id = "updateremarkform" }))
           {%>
        <%: Html.HiddenFor(i => i.Id)%>
        <fieldset>
            <legend>
                <%:"Order remark".Localize() %></legend>
            <table>
                <tbody>
                    <tr>
                        <td>
                            <%: Html.TextAreaFor(i => i.Remark, new { style = "height: 96px; width: 100%;" })%>
                        </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
        <p class="buttons">
            <a id="updateremark" class="button" href="#">
                <%:"Save".Localize() %></a>
        </p>
        <%} %>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        var successMessage = '<%: "Remark has been updated.".Localize() %>';
    </script>
    <%using (var loader = ClientLoader.RegisterInstance())
      {
          loader.Require("order.detail.js");
      } %>
</asp:Content>
